package com.itheima.app.manager.smsManager;


import com.itheima.commons.PageResult;
import com.itheima.commons.R;
import com.itheima.domain.db.sms.SmsHomeAdvertise;
import com.itheima.service.smsService.SmsHomeAdvertiseService;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SmsHomeAdvertiseManager {

    @DubboReference
    SmsHomeAdvertiseService smsHomeAdvertiseService;

    //添加广告
    public R save(SmsHomeAdvertise smsHomeAdvertise){
        smsHomeAdvertiseService.save(smsHomeAdvertise);
        return R.ok("操作成功");
    }

    //删除广告
    public R delete(List<Long> ids){
        smsHomeAdvertiseService.delete(ids);
        return R.ok("删除成功");
    }

    //分页查询
    public R findByPage(String endTime,String name,Integer pageNum,Integer pageSize,Integer type){
        PageResult<SmsHomeAdvertise> page = smsHomeAdvertiseService.findByPage(endTime, name, pageNum, pageSize, type);
        return R.ok(page);
    }

    //修改上下线状态
    public R update(Long id,Integer status){
        smsHomeAdvertiseService.update(id, status);
        return R.ok("操作成功");
    }

    //修改广告
    public R updateById(Long id,SmsHomeAdvertise smsHomeAdvertise){
        smsHomeAdvertiseService.updataById(id,smsHomeAdvertise);
        return R.ok("操作成功");
    }

    //获取广告详情
    public R getAdvertiseById(Long id){
        SmsHomeAdvertise smsHomeAdvertise = smsHomeAdvertiseService.getAdvertiseById(id);
        return R.ok(smsHomeAdvertise);
    }
}
